package com.tianpengtech.front.mobile.region;

import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Record;
import com.tianpengtech.common.model.fair.Fair;
import com.tianpengtech.front.mobile.common.util.R;

import java.util.List;

/**
 * Created by ggd on 2017/7/24 0024.
 */
public class RegionService {
    public static RegionService me = new RegionService();


    public R getProvince(){
        List<Record> list=Db.findByCache(Fair.FAIR_CACHE_NAME,Fair.FAIR_CACHE_REGION,"select REGION_ID,REGION_NAME from region where PARENT_ID=1");
        R r = R.ok("成功");
        r.p("province",list);
        return r;
    }


    public R getCity(long id){
        List<Record> list=Db.findByCache(Fair.FAIR_CACHE_NAME,Fair.FAIR_CACHE_REGION+id,"select REGION_ID,REGION_NAME from region where PARENT_ID=?",id);
        R r = R.ok("成功");
        r.p("city",list);
        return r;
    }
    
    
    public Record findById(String id ){
    	String sql= "select * from region where REGION_ID=?";
    	return Db.findFirst(sql,id);
    }
}
